package com.mdnote.practice.bit;

/**
 * @author Rhythm-2019
 * @version 1.0
 * @date 2020/10/17
 * @description  2的幂
 */
public class LeetCode231 {

    public boolean isPowerOfTwo(int n) {
        if (n == 0 || n == Integer.MIN_VALUE) {
            return false;
        }
        // n & (-n) == n
        n = n & (n - 1);
        return n == 0;
    }


}
